﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:controls="clr-namespace:MVVM.Demo">                    

 


    <!-- MainTabControlTemplateEx -->
    <ControlTemplate x:Key="MainTabControlTemplateEx"
			        TargetType="{x:Type controls:TabControlEx}">
        <Grid>
            
            <Grid.RowDefinitions>
                <RowDefinition x:Name="row0" Height="Auto"/>
                <RowDefinition x:Name="row1" Height="4"/>
                <RowDefinition x:Name="row2" Height="*"/>
            </Grid.RowDefinitions>
            
            <TabPanel x:Name="tabpanel" 
                Background="{StaticResource OutlookButtonHighlight}"
                Margin="0"
		        Grid.Row="0"
		        IsItemsHost="True" />
            
            <Grid x:Name="divider"
                  Grid.Row="1" Background="Black" 
                  HorizontalAlignment="Stretch"/>
                  
            <Grid x:Name="PART_ItemsHolder"
                  Grid.Row="2"/>
        </Grid>
        <!-- no content presenter -->
        <ControlTemplate.Triggers>
            <Trigger Property="TabStripPlacement" Value="Top">
                <Setter TargetName="tabpanel" Property="Grid.Row" Value="0"/>
                <Setter TargetName="divider" Property="Grid.Row" Value="1"/>
                <Setter TargetName="PART_ItemsHolder" Property="Grid.Row" Value="2" />
                <Setter TargetName="row0" Property="Height" Value="Auto" />
                <Setter TargetName="row1" Property="Height" Value="4" />
                <Setter TargetName="row2" Property="Height" Value="*" />
            </Trigger>
            <Trigger Property="TabStripPlacement" Value="Bottom">
                <Setter TargetName="tabpanel" Property="Grid.Row" Value="2" />
                <Setter TargetName="divider" Property="Grid.Row" Value="1" />
                <Setter TargetName="PART_ItemsHolder" Property="Grid.Row" Value="0" />
                <Setter TargetName="row0" Property="Height" Value="*" />
                <Setter TargetName="row1" Property="Height" Value="4" />
                <Setter TargetName="row2" Property="Height" Value="Auto" />
            </Trigger>
        </ControlTemplate.Triggers>

    </ControlTemplate>


    <!-- Tab Close Button Style -->
    <Style x:Key="CloseableTabItemButtonStyle" TargetType="{x:Type Button}">
        <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="BorderBrush" Value="Transparent"/>
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="Foreground" 
                Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
        <Setter Property="HorizontalContentAlignment" Value="Center"/>
        <Setter Property="VerticalContentAlignment" Value="Center"/>
        <Setter Property="Padding" Value="4"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Button}">
                    <Grid>
                        <Border SnapsToDevicePixels="true" x:Name="Chrome" 
                                Background="Transparent" 
                                BorderBrush="{TemplateBinding BorderBrush}" 
                                BorderThickness="{TemplateBinding BorderThickness}" 
                                CornerRadius="2" Opacity="0" />
                        <ContentPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" 
                                HorizontalAlignment="{TemplateBinding 
                                HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" 
                                VerticalAlignment="{TemplateBinding VerticalContentAlignment}" 
                                RecognizesAccessKey="True"/>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter Property="Opacity" TargetName="Chrome" Value="1"/>
                        </Trigger>
                        <Trigger Property="IsPressed" Value="True">
                            <Setter Property="Opacity" TargetName="Chrome" Value="1"/>
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="false">
                            <Setter Property="Foreground" Value="Green"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>




    <Style TargetType="{x:Type TabItem}">
        <Setter Property="Padding" Value="5"/>
        <Setter Property="Foreground" Value="Black"/>
        <Setter Property="Background" Value="{StaticResource OutlookButtonHighlight}"/>
        <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
        <Setter Property="VerticalContentAlignment" Value="Stretch"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type TabItem}">
                    <Border SnapsToDevicePixels="true" x:Name="Bd"
                            Background="{TemplateBinding Background}"
                            BorderThickness="0" BorderBrush="Black">


                        <DockPanel Width="Auto">

                            <Button x:Name="PART_Close" HorizontalAlignment="Center" Margin="3" 
                                        VerticalAlignment="Center" Width="16" Height="16" 
                                        Command="{Binding Path=CloseWorkSpaceCommand}"    
                                        Visibility="{Binding IsCloseable, 
                                            Converter={StaticResource BoolToVisibilityConv}, 
                                            ConverterParameter=True}"                                    
                                        DockPanel.Dock="Right" 
                                        Focusable="False"
                                        Style="{DynamicResource CloseableTabItemButtonStyle}" 
                                        ToolTip="Close Tab">
                                <Path x:Name="Path" Stretch="Fill" StrokeThickness="0.5" 
                                          Stroke="{DynamicResource closeTabCrossStroke}" Fill="Black" 
                                          Data="F1 M 2.28484e-007,1.33331L 1.33333,0L 4.00001,2.66669L 6.66667,6.10352e-005L 8,1.33331L 5.33334,4L 8,6.66669L 6.66667,8L 4,5.33331L 1.33333,8L 1.086e-007,6.66669L 2.66667,4L 2.28484e-007,1.33331 Z " 
                                          HorizontalAlignment="Stretch" VerticalAlignment="Stretch"/>
                            </Button>
                            <Label x:Name="lbl" 
                                    Content="{Binding Path=DisplayName}" 
                                    VerticalAlignment="Center" 
                                    />
                        </DockPanel>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="Selector.IsSelected" Value="True">
                            <Setter Property="Background" TargetName="Bd"
                                    Value="Black"/>
                            <Setter Property="TextElement.Foreground" TargetName="lbl"
                                    Value="Orange"/>
                            <Setter Property="Fill" TargetName="Path" Value="Orange"/>
                        </Trigger>
                        <Trigger Property="IsMouseOver" SourceName="PART_Close" Value="True">
                            <Setter Property="Fill" TargetName="Path" Value="Red"/>
                        </Trigger>
                        <Trigger Property="IsPressed" SourceName="PART_Close" Value="True">
                            <Setter Property="Fill" TargetName="Path" Value="Red"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>




</ResourceDictionary>